package net.anzhuo.service.impl;

import lombok.extern.slf4j.Slf4j;
import net.anzhuo.common.entity.PaginationVO;
import net.anzhuo.dao.GsBusinessProfitsMapper;
import net.anzhuo.entity.GsBusinessProfits;
import net.anzhuo.service.GsBusinessProfitsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Slf4j
public class GsBusinessProfitsServiceImpl implements GsBusinessProfitsService {

	@Autowired
	private GsBusinessProfitsMapper gsBusinessProfitsMapper;



	@Override
	public PaginationVO<GsBusinessProfits> getListWithPage(GsBusinessProfits gsBusinessProfits) {
		PaginationVO<GsBusinessProfits> paginationVO = new PaginationVO<>();
		paginationVO.setList(gsBusinessProfitsMapper.getListWithPage(gsBusinessProfits));
		paginationVO.setTotalCount(gsBusinessProfitsMapper.getCount(gsBusinessProfits));
		paginationVO.setTotalPage((gsBusinessProfitsMapper.getCount(gsBusinessProfits) + gsBusinessProfits.getPageSize() -1)  / gsBusinessProfits.getPageSize());
		paginationVO.setPageNo(gsBusinessProfits.getPageNo());
		return paginationVO;
	}

	@Override
	public List<GsBusinessProfits> getByMd5(String md5) {return gsBusinessProfitsMapper.getByMd5(md5);}

	@Override
	public GsBusinessProfits getById(Long id) {
		return gsBusinessProfitsMapper.getById(id);
	}

	@Override
	public List<GsBusinessProfits> getList() {
		return gsBusinessProfitsMapper.getList();
	}

	@Override
	public List<GsBusinessProfits> getList(GsBusinessProfits gsBusinessProfits) {
		return gsBusinessProfitsMapper.getListByQuery(gsBusinessProfits);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void update(GsBusinessProfits gsBusinessProfits) {
		gsBusinessProfitsMapper.update(gsBusinessProfits);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void save(GsBusinessProfits gsBusinessProfits) {
		gsBusinessProfitsMapper.save(gsBusinessProfits);
	}


	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void delete(GsBusinessProfits gsBusinessProfits) {
		gsBusinessProfitsMapper.delete(gsBusinessProfits);
	}
}
